import json as js
import random as rd
import tkinter as tk


top = tk.Tk()
top.title('questions')

frames = []
for i in range(3):
	frames.append(tk.Frame(top))
	frames[i].pack()

with open('./02_1.json', 'r') as f:
	questions = js.load(f)

e1_v = tk.StringVar()
e1 = tk.Entry(frames[0], textvariable=e1_v)
e1.pack()


t1 = tk.Text(frames[2])
t1.pack()

def GetQuestions():
	t1.delete(1.0, 'end')
	num = e1.get()
	try:
		num = int(num)
	except:
		e1.delet(0, 'end')
		return -1
	for i in range(num):
		t1.insert('insert', '\n' + rd.choice(questions) + '\n')

b1 = tk.Button(frames[1], text='Get', command=GetQuestions)
b1.pack()

tk.mainloop()


# ~ tk.mainloop()
